<?php

// this should be taken from the configuration..
$host = "http://localhost:2000";
// Possibly required for avoiding no-encoding problems with IE
header("Content-Type: text/plain; charset=UTF-8");

switch ($_REQUEST["type"])
{
	case 'login':
		$host .= "/login";
		break;
	case 'logout':
		$host .= "/logout";
		break;
	case 'poll':
		$host .= "/poll";
		break;
	case 'send':
		$host .= "/send";
		break;
	case 'invite':
		$host .= "/invite";
		break;
	case 'join':
		$host .= "/join";
		break;
	case 'part':
		$host .= "/part";
		break;
}

if ($_SERVER["REQUEST_METHOD"] == "GET")
{
	$qp = array();
	foreach ($_GET as $key => $val)
	{
		$qp[] = $key . "=" . urlencode($val);
	}
	$qstr = join('&', $qp);
	$buf = file_get_contents($host . "?" . $qstr);
	//print($host . "?" . $qstr);
}

print $buf;

?>
